const data = [];

exports.resolvers = {
  Query: {
    getUserList: () => {
      return data;
    },
    getUserInfo: (parent, args, context) => {
      const { id } = args;
      return data.filter((item) => item.id === id)[0];
    },
    getVersion: (parent, args, context) => {
      const { version } = context;
      return version;
    },
  },
  Mutation: {
    addUser: (parent, args, context) => {
      const { user } = args;
      const id = data.length;
      data.push({ id, ...user });
      return {
        id,
        ...user,
      };
    },
  },
};
